﻿using System.Collections.Generic;
using System;

namespace Wrox.ProCSharp.Generics
{
    class Program
    {
        public static void Main()
        {

        }
    }
    class DocumentManager<T>
    {
        private readonly Queue<T> _documentQueue = new Queue<T>();
        private readonly object _lockQueue = new object();

        public void AddDocument(T doc)
        {
            lock (_lockQueue)
            {
                _documentQueue.Enqueue(doc);
            }
        }

        public bool IsDocumentAvaliable => _documentQueue.Count > 0;

        public T GetDocument()
        {
            T doc = default;
            lock (_lockQueue)
            {
                doc = _documentQueue.Dequeue();
            }
            return doc;
        }
    }
}
